import json
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import re
import time

point = 0
data = {}

f = open('./111.txt', encoding='utf-8')
# f = open('./localhost_access_log.2021-10-27.txt', encoding='utf-8')
f.seek(point)
# 获取到所有内容的行数
lines = f.readlines()
print(len(lines))
for oneLine in lines:
    time = oneLine[27:32]
    # time = oneLine[46:51]
    if time in data.keys():
        data[time] = data[time] + 1
    else:
        data[time] = 1



fig, ax = plt.subplots(1, 1)
plt.title("Number of requests / minute", fontsize=20)
plt.plot(data.keys(), data.values())
ax.xaxis.set_major_locator(ticker.MultipleLocator(base=10))
# plt.yticks(data.values())
# plt.xticks(list(data.keys())[::10])
plt.show()

del lines

